#include "Misile.h"
#include "Ressources.h"


Misile::Misile(Position p , SDL_Surface *ecran , double coef){
	this->p = p;
	this->ecran = ecran;
	this->coef = coef;
	this->im = Ressources::get_image(TIR);
	SDL_SetColorKey(im, SDL_SRCCOLORKEY, SDL_MapRGB(im->format, 0, 0, 255));

	temp =  (double)SDL_GetTicks()/100.0;
	posIni = p;
}

void Misile::afficher(){
	double tempsAct = (double)SDL_GetTicks()/100.0;
	if(tempsAct - temp > 0.05){
		double vitesse = 5.0;
		temp = tempsAct;
		p.y -= vitesse;
		p.x = (p.y-posIni.y)*coef+posIni.x ;
	}
	SDL_Rect pos;
	pos.x = p.x;
	pos.y = p.y;
	SDL_BlitSurface(im,NULL,ecran,&pos);
}

Position Misile::getPosition(){
	return p;
}

void Misile::setPosition(Position p){
	this->p = p;
}
